<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%><%@ 
	taglib uri="http://www.yaodian100.com/jsp/yaodian100" prefix="yaodian100" %>
<%@taglib uri="/WEB-INF/tld/pageable.tld" prefix="pageable"%>
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
${pu:reqSet('pageableTag', pu:pageableTag('index', 10, 10)) }
${pu:criteriaForName('com.yaodian100.ec.order.entity.ServiceOrders') }
<c-rt:if test="${!empty param.srcType && param.srcType!=null}">
${pu:criteriaAdd(pu:criteria('eq', 'srcType', pu:toInteger(param.srcType))) }
</c-rt:if>
${pu:criteriaAdd(pu:criteria('eq', 'orderId', pu:emptyToNull(param.orderId))) }
${pu:criteriaAdd(pu:criteria('eq', 'serviceId', pu:emptyToNull(param.serviceId))) }
${pu:criteriaAdd(pu:criteria('eq', 'orderSt', pu:emptyToNull(param.orderSt))) }
${pu:criteriaAdd(pu:criteria('eq', 'loginId', pu:emptyToNull(param.loginId)))}
${pu:criteriaAdd(pu:criteria('eq', 'receiverEmail', pu:emptyToNull(param.receiverEmail))) }
${pu:criteriaAdd(pu:criteria('eq', 'receiverMobile', pu:emptyToNull(param.receiverMobile))) }
${pu:criteriaAdd(pu:criteria('eq', 'receiverPhone', pu:emptyToNull(param.receiverPhone))) }
<c-rt:if test="${!empty param.startDate}">
	<c-rt:set var="startDate">
	${param.startDate } 00:00
	</c-rt:set>
</c-rt:if>
<c-rt:if test="${!empty param.endDate}">
	<c-rt:set var="endDate">
	${param.endDate } 23:59
	</c-rt:set>
</c-rt:if>
${pu:criteriaAdd(pu:criteria('ge', 'createDate', pu:toDate(pu:emptyToNull(startDate), 'yyyy-MM-dd HH:mm'))) }
${pu:criteriaAdd(pu:criteria('le', 'createDate', pu:toDate(pu:emptyToNull(endDate), 'yyyy-MM-dd HH:mm'))) }
${pu:criteriaAdd(pu:criteriaIn('reason', pu:toArray(pu:emptyToNull(paramValues.reason)))) }
<c-rt:if test="${!empty param.reasonTp}">
${pu:criteriaAdd(pu:criteria('eq', 'reasonTp', pu:emptyToNull(param.reasonTp))) }
</c-rt:if>
${pu:criteriaAddOrder(pu:criteriaOrderDesc('createDate')) }
${pu:reqSet('results', pu:criteriaResult(pageableTag)) }
<script type="text/javascript" charset="UTF-8" src="/ecadmin/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/ecadmin/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="/ecadmin/css/smoothness.datepick.css" />
<script>
$(function(){
	$('#startDate').datepick({dateFormat:'yy-mm-dd'});
	$('#endDate').datepick({dateFormat:'yy-mm-dd'});
});
</script>
<form name="queryForm" action="<c-rt:url value="/serviceOrder/page.do"/>" method="post">
<input type="hidden" name="iamlazy" value="list"/>
<table>
<tr>
	<td>类型：
		<select name="srcType">
			<option value="">请选择</option>
			<option value="1" ${param.srcType=='1'?'selected="selected"':'' }>退货单</option>
			<option value="2" ${param.srcType=='2'?'selected="selected"':'' }>换货单</option>
			<option value="3" ${param.srcType=='3'?'selected="selected"':'' }>取消单</option>
			<option value="4" ${param.srcType=='4'?'selected="selected"':'' }>配送异常单</option>
			
		</select>
	</td>
	<td></td>
	<td></td>
	<td></td>
</tr>
<tr>
	<td>订单编号：<input type="text" name="orderId" value="${param.orderId }"/></td>
	<td>服务单编号：<input type="text" name="serviceId" value="${param.serviceId }"/></td>
	<td>状态:
<select name="orderSt">
		<option value="">请选择</option>
		<option value="00" ${param.orderSt=='00'?'selected="selected"':'' }>审核中</option>
		<option value="10" ${param.orderSt=='10'?'selected="selected"':'' }>申请中</option>
		<option value="20" ${param.orderSt=='20'?'selected="selected"':'' }>退款处理中</option>
		<option value="30" ${param.orderSt=='30'?'selected="selected"':'' }>异常</option>
		<option value="50" ${param.orderSt=='50'?'selected="selected"':'' }>逾期</option>
		<option value="60" ${param.orderSt=='60'?'selected="selected"':'' }>商品退回</option>
		<option value="70" ${param.orderSt=='70'?'selected="selected"':'' }>失败</option>
		<option value="80" ${param.orderSt=='80'?'selected="selected"':'' }>取消</option>
		<option value="90" ${param.orderSt=='90'?'selected="selected"':'' }>完成</option>
	</select>
	</td>
	<td>理由类别:
	<select name="reasonTp">
		<option value="">请选择</option>
		<option value="01" ${param.reasonTp=='01'?'selected="selected"':'' }>使用者取消</option>
		<option value="02" ${param.reasonTp=='02'?'selected="selected"':'' }>系统取消</option>
		<option value="03" ${param.reasonTp=='03'?'selected="selected"':'' }>运费返还</option>
		<option value="04" ${param.reasonTp=='04'?'selected="selected"':'' }>客服修改订单</option>		
	</select>
	</td>
</tr>
<tr>
	<td>会员帐号：<input type="text" name="loginId" value="${param.loginId }"/></td>
	<td>会员email：<input type="text" name="receiverEmail" value="${param.receiverEmail }"/></td>
	<td>会员手机：<input type="text" name="receiverMobile" value="${param.receiverMobile }"/></td>
	<td>会员固定电话：<input type="text" name="receiverPhone" value="${param.receiverPhone }"/></td>
</tr>
<tr>
	<td>日期起：<input type="text" id="startDate" name="startDate" value="${param.startDate }"/></td>
	<td>日期迄：<input type="text" id="endDate" name="endDate" value="${param.endDate }"/></td>
	<td>
	<%--
退换货原因：
	${pu:reqSet('reasonArray', pu:toArray(pu:emptyToNull(paramValues.reason))) }
	<table><tr><td>
	<br/><input type="checkbox" name="reason" value="订购错误" ${pu:isIn('订购错误', reasonArray)?'checked="checked"':'' }/>订购错误
	<br/><input type="checkbox" name="reason" value="外包装破损" ${pu:isIn('外包装破损', reasonArray)?'checked="checked"':'' }/>外包装破损
	<br/><input type="checkbox" name="reason" value="更换商品颜色" ${pu:isIn('更换商品颜色', reasonArray)?'checked="checked"':'' }/>更换商品颜色
	<br/><input type="checkbox" name="reason" value="商品规格不符" ${pu:isIn('商品规格不符', reasonArray)?'checked="checked"':'' }/>商品规格不符
	<br/><input type="checkbox" name="reason" value="收㺫非新品" ${pu:isIn('收㺫非新品', reasonArray)?'checked="checked"':'' }/>收㺫非新品
	<br/><input type="checkbox" name="reason" value="商品发错" ${pu:isIn('商品发错', reasonArray)?'checked="checked"':'' }/>商品发错
	<br/><input type="checkbox" name="reason" value="商品本身破损" ${pu:isIn('商品本身破损', reasonArray)?'checked="checked"':'' }/>商品本身破损
	<br/><input type="checkbox" name="reason" value="更换商品尺寸" ${pu:isIn('更换商品尺寸', reasonArray)?'checked="checked"':'' }/>更换商品尺寸
	<br/><input type="checkbox" name="reason" value="与介绍不符" ${pu:isIn('商品本身破损', reasonArray)?'checked="checked"':'' }/>与介绍不符
	<br/><input type="checkbox" name="reason" value="缺少配件或赠品" ${pu:isIn('缺少配件或赠品', reasonArray)?'checked="checked"':'' }/>缺少配件或赠品
	<br/><input type="checkbox" name="reason" value="其他" ${pu:isIn('其他', reasonArray)?'checked="checked"':'' }/>其他
	</td>
	<td valign="top">
	
	<br/><input type="checkbox" name="reason" value="商品发错" ${pu:isIn('商品发错', reasonArray)?'checked="checked"':'' }/>商品发错
	<br/><input type="checkbox" name="reason" value="商品或外包装破损" ${pu:isIn('商品或外包装破损', reasonArray)?'checked="checked"':'' }/>商品或外包装破损
	<br/><input type="checkbox" name="reason" value="商品不如预期" ${pu:isIn('商品不如预期', reasonArray)?'checked="checked"':'' }/>商品不如预期
	<br/><input type="checkbox" name="reason" value="商品属性不符" ${pu:isIn('商品属性不符', reasonArray)?'checked="checked"':'' }/>商品属性不符
	<br/><input type="checkbox" name="reason" value="价格比较贵" ${pu:isIn('价格比较贵', reasonArray)?'checked="checked"':'' }/>价格比较贵
	
	<br/><input type="checkbox" name="reason" value="改买其他款式" ${pu:isIn('改买其他款式', reasonArray)?'checked="checked"':'' }/>改买其他款式
	<br/><input type="checkbox" name="reason" value="商品未如期收到" ${pu:isIn('商品未如期收到', reasonArray)?'checked="checked"':'' }/>商品未如期收到
	<br/><input type="checkbox" name="reason" value="不会使用" ${pu:isIn('不会使用', reasonArray)?'checked="checked"':'' }/>不会使用
	</td>
	</tr>
	</table>
	--%>
	</td>
	<td></td>
</tr>
<tr>
	<td>
	<input type="submit" value="查询"/>
	<input type="reset" value="重置"/>
	</td><td></td><td></td><td></td>
</tr>
</table>
</form>
<table class="tb-1" width="100%">
		<thead>
			<tr>
				<th></th>
				<th>类型</th>
				<th>订单编号</th>
				<th>服务单编号</th>
				<th>会员</th>
				<th>商品名称</th>
				<th>退货金额</th>
				<th>退货原因</th>
				<th>退货期限</th>
				<th>状态</th>
				<th>功能</th>
				
			</tr>
		</thead>
		<tbody>
		<c-rt:forEach items="${results }" var="result">
		${pu:reqSet('sopsParams', null) }
		${pu:listAdd('sopsParams', result.serviceId) }
		${pu:reqSet('sops', pu:queryByHql('from ServiceOrderProduct where serviceId=?', pu:arrayGet('sopsParams'), null))  }
		
			<tr>
				<td></td>
				<td>
				<c-rt:choose>
					<c-rt:when test="${result.srcType=='1'}">
					退货单
					</c-rt:when>
					<c-rt:when test="${result.srcType=='2'}">
					换货单
					</c-rt:when>
					<c-rt:when test="${result.srcType=='3'}">
					取消单
					</c-rt:when>
					<c-rt:otherwise>
					配送异常单
					</c-rt:otherwise>
				</c-rt:choose>
				</td>
				<td>
				<a href="<c-rt:url value="/order/view.do?orderId=${result.orderId }"/>">
				${result.orderId }
				</a>
				</td>
				<td><a href="<c-rt:url value="/serviceOrder/page.do?iamlazy=detail&from=list&serviceId=${result.serviceId }"/>">${result.serviceId }</a></td>
				<td>${result.loginId }</td>
				<td style="text-align:left">
				<c-rt:forEach items="${sops }" var="sop">
					${sop.prodName }<br/>
					
					
					${pu:reqSet('order', pu:get('com.yaodian100.ec.order.entity.Orders', sop.orderId)) }
					<c-rt:forEach items="${order.orderProduct}" var="orderProduct">
					<c-rt:if test="${sop.orderProdId==orderProduct.orderProdId}">
					
					<c-rt:forEach items="${orderProduct.applyCampaigns}" var="ac">
	          	
	          	<p>
	          	<c-rt:if test="${ac.active}">
	          		<span class="type-4" style="color:red">优惠</span>
	          	</c-rt:if>
	          	<c-rt:if test="${!ac.active}">
	          		<span class="type-6"  style="color:gray">优惠</span>（不符合）
	          	</c-rt:if>
	          <c-rt:if test="${ac.campaignUrl!=null}">
	          	<a target="_blank" class="a-red" href="${ac.campaignUrl }">${ac.campaignName }</a>
	          	</c-rt:if>
	          	<c-rt:if test="${ac.campaignUrl==null}">
	          	
	          	${pu:reqSet('pc', pu:get('com.yaodian100.ec.campaign.entity.Campaign', ac.campaignUuid)) }
	          	
	          	${ac.campaignName }
	          	
	          	</c-rt:if>
	          	</p>
	          	<br/>
	          	</c-rt:forEach>
				</c-rt:if>
				</c-rt:forEach>
					
					
				</c-rt:forEach>
				</td>
				<td>${result.returnBenefit+result.returnBonus+result.returnCash+result.returnMyWallet+result.returnInstallmentFee }</td>
				<td>${result.reason }</td>
				<td><c-rt:if test="${!empty sops[0].logisticFinalDt}">
				<fmt-rt:formatDate value="${pu:addDays(sops[0].logisticFinalDt, 7) }" pattern="yyyy-MM-dd"/>
				</c-rt:if></td>
				<td>
				
				<c-rt:if test="${result.orderSt=='00' }">审核中</c-rt:if>
				<c-rt:if test="${result.orderSt=='10' }">申请中</c-rt:if>
				<c-rt:if test="${result.orderSt=='20' }">退款处理中</c-rt:if>
				<c-rt:if test="${result.orderSt=='30' }">异常</c-rt:if>
				<c-rt:if test="${result.orderSt=='40' }">换货转退货</c-rt:if>
				<c-rt:if test="${result.orderSt=='50' }">逾期</c-rt:if>
				<c-rt:if test="${result.orderSt=='60' }">商品退回</c-rt:if>
				<c-rt:if test="${result.orderSt=='70' }">失败</c-rt:if>
				<c-rt:if test="${result.orderSt=='80' }">取消</c-rt:if>
				<c-rt:if test="${result.orderSt=='90' }">完成</c-rt:if>
				
				</td>
				<td>
				<c-rt:if test="${result.orderSt=='00' && result.srcType=='1'}">
				<input type="button" onclick="location.href='<c-rt:url value="/serviceOrder/confirmReturnProduct.do?serviceId=${result.serviceId }"/>'" value="审核成功"/>
				<input type="button" onclick="location.href='<c-rt:url value="/serviceOrder/cancelReturnProduct.do?serviceId=${result.serviceId }"/>'" value="审核失败"/>
				
				<%--
				<input type="button" onclick="doAR('<c-rt:url value="/serviceOrder/confirmReturnProduct.do?serviceId=${result.serviceId }"/>', 'main', 'queryForm')" value="审核成功"/>
				<input type="button" onclick="doAR('<c-rt:url value="/serviceOrder/cancelReturnProduct.do?serviceId=${result.serviceId }"/>', 'main', 'queryForm')" value="审核失败"/>
				--%>
				<input type="button" onclick="location.href='/ecadmin/serviceOrder/toReturnToChange.do?serviceId=${result.serviceId }'" value="退货转换货"/>
				</c-rt:if>
				<c-rt:if test="${result.orderSt=='80'}"><yaodian100:checkPermission permissions="GROUP_A-30-400-000">
				<input type="button" onclick="location.href='<c-rt:url value="/serviceOrder/revertCancel.do?serviceId=${result.serviceId }"/>'" value="回复审核"/>
				</yaodian100:checkPermission></c-rt:if>
				<c-rt:if test="${result.orderSt=='00' or result.orderSt=='10'}"><yaodian100:checkPermission permissions="GROUP_A-30-400-000">
				<c-rt:if test="${result.srcType=='1' || result.srcType=='2'}">
				<input type="button" onclick="location.href='<c-rt:url value="/serviceOrder/delServiceOrder.do?serviceId=${result.serviceId }"/>'" value="删除"/>
				</c-rt:if>
				</yaodian100:checkPermission></c-rt:if>
				<c-rt:if test="${result.srcType=='1' || result.srcType=='2'}">
					<input type="button" onclick="location.href='<c-rt:url value="/serviceOrder/trackcase/add.do?orderIdParam=${result.orderId}&serviceIdParam=${result.serviceId}&caseTypeParam=${result.srcType}"/>'" value="追踪"/>
				</c-rt:if >
				</td>
			</tr>
		</c-rt:forEach>
		</tbody>
	</table>
	<c-rt:if test="${empty results}">
	<table width="100%">
		<tr>
			<td align="center">没有符合条件的资料！</td>
		</tr>
	</table>
	</c-rt:if>
	<c-rt:set var="url">
	<c-rt:url value="/serviceOrder/page.do?iamlazy=list"/>
	</c-rt:set>
<pageable:Pageable url="${url}" formname="serviceOrderForm" escapeparams="iamlazy" key="index"></pageable:Pageable>
